Skip to content

Merge nested concat Ops optimization pass in ONNX dialect #3111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Apr 16, 2025

Conversation

Arkar-Hema
Copy link
Contributor

Concat merging

The RecomposeConcat pass is an ONNX-MLIR optimization pass that simplifies and merges ONNXConcatOp operations to improve model performance and reduce redundant operations.

The pass optimizes Concat operations by:

  • Identifies Concat layers with the same axis and combines their inputs into a single Concat node.
  • If the Concat has only one input, it directly replaces the Concat with that input.

Input Representation

  • Input tensors: {X1,X2,...,Xn}
  • Concat axis: A
  • Shape of each tensor: (N, C, H, W)

Original Flow (Nested Concat Operations)

  • A Concat operation has an input that is itself a Concat:
    Y=Concat(X1,Concat(X2,X3),X4)
  • Computational Cost: Each Concat operation involves memory allocations and data movement
    image

Optimized Flow (Flattening Nested Concats)

  • Instead of a nested structure, the pass flattens the Concat operations:
    Y=Concat(X1,X2,X3,X4)
  • Computational Savings: Since Concat now operates in a single step, memory and computation are optimized
    image
  • The reduction factor in computation can be expressed as:
    image

@jenkins-droid
Copy link
Collaborator

Can one of the admins verify this patch?

@Arkar-Hema Arkar-Hema closed this Apr 8, 2025
@jenkins-droid
Copy link
Collaborator

Can one of the admins verify this patch?

@Arkar-Hema Arkar-Hema reopened this Apr 8, 2025
@jenkins-droid
Copy link
Collaborator

Can one of the admins verify this patch?

Signed-off-by: Arkar-Hema <[email protected]>
Signed-off-by: Arkar-Hema <[email protected]>
@jenkins-droid
Copy link
Collaborator

Can one of the admins verify this patch?

@jenkins-droid
Copy link
Collaborator

Can one of the admins verify this patch?

@jenkins-droid
Copy link
Collaborator

Can one of the admins verify this patch?

Signed-off-by: Arkar-Hema <[email protected]>
@jenkins-droid
Copy link
Collaborator

Can one of the admins verify this patch?

Signed-off-by: Arkar-Hema <[email protected]>
@jenkins-droid
Copy link
Collaborator

Can one of the admins verify this patch?

Copy link
Collaborator

@tungld tungld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some minor changes!

@jenkins-droid
Copy link
Collaborator

Can one of the admins verify this patch?

@jenkins-droid
Copy link
Collaborator

Can one of the admins verify this patch?

@tungld tungld merged commit 55e335e into onnx:main Apr 16, 2025
7 checks passed
@jenkins-droid
Copy link
Collaborator

Jenkins Linux ppc64le Build #15502 [push] Merge nested concat Ops ... started at 07:46

@jenkins-droid
Copy link
Collaborator

Jenkins Linux s390x Build #16521 [push] Merge nested concat Ops ... started at 07:46

@jenkins-droid
Copy link
Collaborator

Jenkins Linux amd64 Build #16519 [push] Merge nested concat Ops ... started at 06:46

@jenkins-droid
Copy link
Collaborator

Jenkins Linux amd64 Build #16519 [push] Merge nested concat Ops ... passed after 1 hr 29 min

@jenkins-droid
Copy link
Collaborator

Jenkins Linux s390x Build #16521 [push] Merge nested concat Ops ... passed after 1 hr 41 min

@jenkins-droid
Copy link
Collaborator

Jenkins Linux ppc64le Build #15502 [push] Merge nested concat Ops ... passed after 2 hr 30 min

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants